package com.hc.ureport.controller.api;

import com.alibaba.fastjson.JSON;
import com.hc.ureport.model.HttpResultModel;
import com.hc.ureport.service.MainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = {"【API】首页接口"})
@RestController
@RequestMapping("/api/main")
@Slf4j
public class MainController {

    @Resource
    private MainService mainService;


    @ApiOperation(value = "通知回调地址")
    @PostMapping(value = "/notify/callback")
    public HttpResultModel<String> notifyCallback(@RequestBody Object data) {
        try {
            log.info(String.valueOf(data));
//            JSONObject jsonObject = new JSONObject(data);
//            Log.i(jsonObject);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }

        return HttpResultModel.sendResult(JSON.toJSONString(data));
    }

}
